package com.wei.util;

public class AMSD  implements Count{

    String  s;
    double sum;
    AS as;
    MD md;

    public AS getAs() {
        return as;
    }

    public void setAs(AS as) {
        this.as = as;
    }

    public MD getMd() {
        return md;
    }

    public void setMd(MD md) {
        this.md = md;
    }

    public AMSD(AS as, MD md) {
        this.as = as;
        this.md = md;
    }

    public  String calculate() {//获取运算表达式
        int a=(int) (Math.random()*2);

        if(a==0){
            s= as.calculate();
            sum=as.sum;
        }
        if(a==1){
            s= md.calculate();
            sum=md.sum;
        }
        return s;
    }

    public  double answer(){//获取结果
        sum = (double) Math.round(sum * 100) / 100;
        return sum;
    }
}
